package com.jboost.hyk.common.constant;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import com.jboost.common.constant.CommonConstant;
import com.jboost.common.constant.EnumInterface;

public enum BusinessKnowledgePointStatusEnum implements EnumInterface {
    // 状态：valid-正常；soon_expire-即将到期；expired-已过期；
    VALID("valid", "正常"),
    SOON_EXPIRE("soon_expire", "即将到期"),
    EXPIRED("expired", "已过期");

    BusinessKnowledgePointStatusEnum(String code, String desc) {
        this.code = code;
        this.value = desc;
        this.desc = desc;
    }

    @EnumValue
    @JsonValue    //标记响应json值
    private final String code;
    private final String value;
    private final String desc;

    public String getCode() {
        return code;
    }

    public String getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }
    public static BusinessKnowledgePointStatusEnum getByCode(String code) {
        BusinessKnowledgePointStatusEnum[] enums = BusinessKnowledgePointStatusEnum.values();
        for (int i = 0; i < enums.length; i++) {
            if(enums[i].code.equals(code)){
                return enums[i];
            }
        }
        return null;
    }
    public static String getValueByCode(String code) {
        BusinessKnowledgePointStatusEnum status = BusinessKnowledgePointStatusEnum.getByCode(code);
        if(null == status){
            return CommonConstant.UNDIFIND_DEFALUT;
        }
        return status.getValue();
    }
    public static String getDescByCode(String code) {
        BusinessKnowledgePointStatusEnum status = BusinessKnowledgePointStatusEnum.getByCode(code);
        if(null == status){
            return CommonConstant.UNDIFIND_DEFALUT;
        }
        return status.getDesc();
    }

    @Override
    public String desc() {
        return this.desc;
    }

    @Override
    public Integer value() {
        return null;
    }

    @Override
    public String code() {
        return this.code;
    }


}
